package test;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;

public class Sender {

    public static void main(String[] args) {
        try {
//            Socket socket = new Socket("192.168.10.44", 8888);
            Socket socket = new Socket("127.0.0.1", 8888);
//            InputStream is = socket.getInputStream();
            OutputStream os = socket.getOutputStream();
//            InputStreamReader isr = new InputStreamReader(is);
//            BufferedReader br = new BufferedReader(isr);
            PrintWriter pw = new PrintWriter(os);
            pw.println("dddddddddddddddddddd");
            pw.flush();
            /*Runnable r = new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        // 发送信息

                        try {
                            Scanner scan = new Scanner(System.in);
                            String msg = scan.nextLine();
                            pw.println(msg);
                            pw.flush();
                        } catch (Exception e) {
                        }

                    }

                }
            };

            Runnable r2 = new Runnable() {
                @Override
                public void run() {
                    // 接受发送的信息
                    while (true) {
                        String str;
                        try {
                            str = br.readLine();
                            System.out.println("接受者receiver:" + str);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            };
            Thread t1 = new Thread(r);
            Thread t2 = new Thread(r2);
            t1.start();
            t2.start();*/
            Thread.sleep(100000000L);
        } catch (UnknownHostException e) {

            e.printStackTrace();
        } catch (IOException e) {

            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
